app.controller("abcCtrl", ['$scope', '$modal', '$rootScope', 'FileUploader', 'editableOptions', 'editableThemes', function($scope, $modal, $rootScope, FileUploader, editableOptions, editableThemes) {
    $scope.demo = {};
    $scope.demo.boo = false;
    $scope.demo.classtype = "btn m-b-xs w-xs btn-default btn-rounded";
    $scope.demo.value = "abc";
    $scope.demo.BUTTON = '<winit-button isdisabled="demo.isdisabled" isshow="demo.isshow" value="demo.value"\n' +
        '                                      back-data="\'button function测试数据\'" fon-click="aa(backData)"></winit-button>';
    $scope.click = function(x) {
        console.log(x);
    }
    $scope.demo.backData = "回调参数";


    $scope.demo.field = "例子";
    $scope.demo.selectData = [{ name: 'a', age: 'b' }, { name: 'x', age: 'y' }, { name: 'n', age: 'm' }];
    $scope.demo.optiondata = 'name';
    $scope.demo.widthdata = "300px";
    $scope.demo.select = '<winit-select fon-change="selectedThis(selectedData)" widthdata="demo.widthdata" label="demo.field" optiondata="demo.optiondata" selectdata="demo.selectData" ></winit-select>\n';
    $scope.selectedThis = function(x) {
        console.log(x);
    }

    $scope.validateData = function(isPass) {
        console.log(isPass);
    }

    //************Xeditable****************/
    editableThemes.bs3.inputClass = 'input-sm';
    editableThemes.bs3.buttonsClass = 'btn-sm';
    editableOptions.theme = 'bs3';
    $scope.user = {
        name: 'awesome',
        desc: 'Awesome user \ndescription!'
    }
    /////////////////////////////

    $scope.info = {};
    $scope.info.textdata = "abcd";
    $scope.info.data = { 'vastat': false };
    $scope.info.validate = {
        'required': {
            "validate": true,
            "msg": "必填项"
        },
        'regex': {
            "validate": "^[a-zA-Z0-9]{4,10}$",
            "msg": "输入4-10位的字符串"
        }
    }
    $scope.validateData = function(x) {
        console.log(x);
    }
    $scope.demo.Input = '<winit-text  textdata="info.textdata" fon-blur="validateData(backdata)" data="info.data" validate="info.validate"></winit-text>';

    $scope.info.titleData = "title";
    $scope.info.bodyData = "body";
    $scope.openWin = function() {

        $rootScope.confirmWindow($scope.info, function() {

        })
    }
    $scope.demo.BUTTONS = "<winit-buttons fon-click=\"click(type)\" isdisabled=\"demo.boo\"></winit-buttons>";
    $scope.demo.TEXTAREA = "<winit-textarea  textdata=\"info.textdata\" data=\"info.data\" validate=\"info.validate\" fon-blur=\"validateData(backdata)\"></winit-textarea>\n"

    $scope.demo.checkData = [{
            "a": "A",
            "check": false
        },
        {
            "a": "Z",
            "check": false
        },
        {
            "a": "M",
            "check": false
        }
    ]
    $scope.demo.a = "a";
    $scope.demo.b = "b";
    $scope.checkThis = function(x) {
        console.log(x);
    }
    $scope.demo.CHECKBOX = "<winit-checkbox ischeck=\"demo.boo\"></winit-checkbox>";
    $scope.demo.CHECKBOXS = "checkboxs：<winit-checkboxs check-list=\"demo.checkData\"></winit-checkboxs>";

    //tree
    $scope.info.testTree = [{
        label: 'Animal',
        status: 'update',
        children: [{
            label: 'Dog',
            status: 'add',
            data: {
                description: "man's best friend"
            }
        }, {
            label: 'Cat',
            status: 'delete',
            data: {
                description: "Felis catus"
            }
        }, {
            label: 'Hippopotamus',
            data: {
                description: "hungry, hungry"
            }
        }, {
            label: 'Chicken',
            children: ['White Leghorn', 'Rhode Island Red', 'Jersey Giant']
        }]
    }];
    $scope.info.TREE = "<m-tree tree-data=\"info.testTree\" blur=\"treeClick(info)\" tree-blur=\"selected(info)\"></m-tree>";

    $scope.test = function() {

        $rootScope.editTreeWindow("FETURE", function(data) {

        })
    }





    $scope.info.date = { label: 'aaaaaa', selectDt: '2017-10-10' };
    $scope.info.mhtml = '<ul><li>2017-10-10hfjfgjfhjfgj<br></li></ul>';

    $scope.info.swdata = [{ 'label': 'xxxxx' }, { 'label': 'xxxxx1', 'check': true }];
    $scope.switchClick = function() {
        alert();
        $scope.demo.admin = "admin";

    }
    // 链接websocket
    $scope.demo.userName='admin';
    $scope.demo.passWord='admin123';
    $scope.demo.sockJsUrl='127.0.0.1';
    $scope.openWebSocket = function() {
        if(!$scope.demo.sockJsUrl){
            alert('请输入rabbit地址')
            return;
        }
        if(!$scope.demo.userName){
            alert('请输入rabbit用户名')
            return;
        }
        if(!$scope.demo.passWord){
            alert('请输入rabbit密码')
            return;
        }
        var queue="MATRIX_TEST_SEND.MATRIX.TEST.ALL.CNR";
        
       $rootScope.openWebSocket($scope.demo.sockJsUrl,$scope.demo.userName,$scope.demo.passWord,queue);
    }

    $scope.openRabbitTest=function(){
        window.open("http://"+$scope.demo.sockJsUrl+':15670/')
    }

    $scope.onclose=function(){
        $rootScope.ws.close();
    }

    
    

    $scope.change = function(x) {
        console.log('demo', x);
    }

    $scope.slider = {
        minValue: 5,
        maxValue: 8,
        options: {
            showTicksValues: true,
            stepsArray: [
                { value: 1, legend: 'Very poor' },
                { value: 2 },
                { value: 3, legend: 'Fair' },
                { value: 4 },
                { value: 5, legend: 'Average' },
                { value: 6 },
                { value: 7, legend: 'Good' },
                { value: 8 },
                { value: 9, legend: 'Excellent' }
            ]
        }
    };
}])